//ascii cmp
// $Id: ascii_strcmp.h 262 2009-11-12 18:48:22Z Oleg.Bulychov $
#pragma once


#define ASCII_TOLOWER(c) ( (((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c) )

inline int ascii_strcmp(char const* left, char const* right)
{
    for(;;++left, ++right)
    {
        int d = (int)(*(unsigned char*)left) -
                (int)(*(unsigned char*)right);
        if (!*left || d)
            return d;
    }
}

inline int ascii_strcmpi(char const* left, char const* right)
{
    for(;;++left, ++right)
    {
        int d = (int)(*(unsigned char*)left) -
                (int)(*(unsigned char*)right);
        if (d)
            d = (int)ASCII_TOLOWER(*(unsigned char*)left) -
                (int)ASCII_TOLOWER(*(unsigned char*)right);
        if (!*left || d)
            return d;
    }
}

//EOF!
